package com.samuel.learning.multithread.interview;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {

    public static final String yyyy_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";

    public static void main(String[] args) {

        String time = "2018-6-27 2:23:34";

        SimpleDateFormat df = new SimpleDateFormat(yyyy_MM_DD_HH_MM_SS);
        try {
            Date cTime = df.parse(time);
            LocalDateTime localDateTime = LocalDateTime.ofInstant(cTime.toInstant(), ZoneId.systemDefault());
            System.out.println(localDateTime.getDayOfMonth());
            System.out.println(localDateTime.getDayOfWeek());
            System.out.println(localDateTime.getDayOfYear());
            System.out.println(localDateTime.getHour());
            System.out.println(localDateTime.getMinute());
            System.out.println(localDateTime.getMonthValue());
            long day = LocalDate.now().until(localDateTime.toLocalDate(), ChronoUnit.DAYS);
            System.out.println(day);
        //    System.out.println(day.equals(1L));
            System.out.println(1==day);
        } catch (ParseException e) {
            e.printStackTrace();
        }


    }
}
